﻿@{
    Layout = null;
    var list = ViewData["olist"] as IList<Sc.Domain.CommOrgz>;
}
<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <link href="~/Content/css/style.css" rel="stylesheet" />
    <link href="~/Content/css/select.css" rel="stylesheet" />
    <script src="~/Scripts/jquery-1.10.2.min.js"></script>
    <script src="~/Scripts/select-ui.min.js"></script>
    <script src="~/Content/layer-v2.1/layer/layer.js"></script>
    <script src="~/Scripts/comm.js"></script>
    <title>车辆选择</title>
    <script type="text/javascript">
        $(document).ready(function (e) {
            $(".select2").uedSelect({
                width: 110
            });
            loadData(0,"");
        });
        //数据加载
        function loadData(orgz, carNo) {
            var url = '@Url.Action("GetPageData")';
            var load = loadTip("数据加载中，请稍候", 16, 0);
            $.get(url, { orgz: orgz, carNo: carNo }, function (data) {
                var table = document.getElementById("listData");
                $("#listData").find("tr").remove();
                $.each(data, function (index, n) {
                    var row = table.insertRow(table.rows.length);
                    row.Id = n.Id;
                    var cb = row.insertCell(0);
                    cb.innerHTML = "<input type='radio' name='group' tag=" + n.Id + " carNo=" + n.CarNo + " />";
                    var img = row.insertCell(1);
                    img.className = "imgtd";
                    img.innerHTML = "<img width='100px' src='../UploadFiles/CarImg/" + n.ImageUrl + "' />";
                    var carNo = row.insertCell(2);
                    carNo.innerHTML = n.CarNo;
                    var driver = row.insertCell(3);
                    driver.innerHTML = n.DriverName;
                    var take = row.insertCell(4);
                    take.innerHTML = n.TakeCount;
                    var carType = row.insertCell(5);
                    carType.innerHTML = n.CarTypeName;
                    var cno = row.insertCell(6);
                    cno.innerHTML = n.ChassisNumber;
                    var color = row.insertCell(7);
                    color.innerHTML = n.CarColor;
                    var pl = row.insertCell(8);
                    pl.innerHTML = n.CarDisplacement;
                });
                $('.imgtable tbody tr:odd').addClass('odd');
                layer.close(load);
            });
        }
        //查询
        function search() {
            var orgz = $("#selOrgz").val();
            var carNo = $("#txtCarNo").val();
            loadData(orgz, carNo);
        }
        //确定选择
        function sure() {
            var radio = $("#listData").find("input[type=radio]:checked");
            if (radio.length <= 0) {
                loadTip("请至少选择一辆车", 2, 1000);
                return false;
            }
            if (radio.length > 1) {
                loadTip("只能选择一辆车", 2, 1000);
                return false;
            }
            var car = $(radio[0]);
            self.parent.sureCarInfo(car.attr("tag"),car.attr("carNo"));
        }
    </script>
</head>
<body>
    <div class="rightinfo">
        <div class="tools">
            <ul class="toolbar">
                <li class="click" onclick="sure();"><span><img src="~/Content/images/t01.png" /></span>确定</li>
            </ul>
            <input type="hidden" id="busId" value="0" />
            <ul class="seachform" style="float:right;">
                <li>
                    <label>单位</label>
                    <div class="vocation">
                        <select name="select" class="select2" id="selOrgz">
                            @foreach (var item in list)
                            {
                                <option value="@item.Id">@item.OrgzName</option>
                            }
                        </select>
                    </div>
                </li>
                <li>
                    <label>车牌号</label>
                    <input type="text" id="txtCarNo" style="width:110px" class="scinput" />
                </li>
                <li>
                    <label>&nbsp;</label>
                    <input type="button" class="scbtn" onclick="loadData();" value="查询" />
                </li>
            </ul>
        </div>
        <table class="imgtable">
            <thead>
                <tr>
                    <th width="30px"></th>
                    <th width="100px;">缩略图</th>
                    <th>车牌号</th>
                    <th>驾驶员</th>
                    <th>准载人数</th>
                    <th>车型</th>
                    <th>车架号</th>
                    <th>车颜色</th>
                    <th>排量</th>
                </tr>
            </thead>
            <tbody id="listData"></tbody>
        </table>
    </div>
</body>
</html>
